<template>
   <div class="box">
      <div class="header">
        <van-nav-bar title="首页" />
      </div>
      <div class="content">
         <!--商品列表-->
          <ul>
              <li v-for="item in list" :key="item.id" @click="$router.push('/detail/'+item.id)">
                  <div><img :src="item.image" alt=""></div>
                  <div>
                      <p class="van-multi-ellipsis--l2">{{item.title}}</p>
                      <p style="color:red;">￥{{item.price}}</p>
                  </div>
              </li>
          </ul>
      </div>
    </div>
</template>

<script setup>
import request from '@/utils/request'
import {ref,onMounted} from 'vue'
const list =ref([])
onMounted(()=>{
     //请求列表数据
     request.get('/list').then(res=>{
        if(res.data.code==200)
        {
            list.value=res.data.data
        }
     })
})
</script>

<style lang="scss" scoped>
ul{
    column-count: 2;
    column-gap: 10px;
    li{
        break-inside: avoid;
        img{
            width: 100%;
        }
    }
}
</style>